package com.eshop.xss;

import com.eshop.utils.html.EscapeUtil;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;

public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
{
    public XssHttpServletRequestWrapper(final HttpServletRequest request) {
        super(request);
    }
    
    public String[] getParameterValues(final String name) {
        final String[] values = super.getParameterValues(name);
        if (values != null) {
            final int length = values.length;
            final String[] escapseValues = new String[length];
            for (int i = 0; i < length; ++i) {
                escapseValues[i] = EscapeUtil.clean(values[i]).trim();
            }
            return escapseValues;
        }
        return super.getParameterValues(name);
    }
}
